package com.aishuang.feign.clients.fail;

import com.aishuang.feign.clients.UserClient;
import com.aishuang.feign.pojo.User;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;

/**
 * @Title: UserClientFallbackFactory
 * @Description:
 * @Auther: py
 * @Version: 1.0
 * @create 2024/3/11 13:45
 */
@Slf4j
public class UserClientFallbackFactory implements FallbackFactory<UserClient> {
    @Override
    public UserClient create(Throwable throwable) {
        return new UserClient() {
            @Override
            public User findById(Long id) {
                log.error("查询用户异常", throwable);
                User user = new User();
                user.setUsername("默认用户...");
                return user;
            }
        };
    }
}
